var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("GameEm"),
    s = t("CarMoveCom"),
    c = t("CatMoveCom"),
    p = cc._decorator,
    l = p.ccclass,
    d =
        (p.property,
        p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.catIndexId = 0;
                e.parentSort = null;
                e.firstNode = null;
                e.catParentNode = null;
                e.maxHeight = -1;
                return e;
            }
            e.prototype.checkSort = function () {
                var t = this;
                EVUIEffView.emit(EVUIEffView.callSort, function (e) {
                    t.parentSort = e;
                });
            };
            e.prototype.onLoad = function () {
                EvCat.on(EvCat.makeCat0, this.makeCat.bind(this), this);
                EvCat.on(EvCat.makeCar0, this.makeCar.bind(this), this);
            };
            e.prototype.onDestroy = function () {
                EvCat.offTarget(this);
            };
            e.prototype.makeCar = function (t, e, o, a, i) {
                this.addCarTask(e, o, a, i);
            };
            e.prototype.addCarTask = function (t, e, o, a) {
                var i = this;
                this.checkSort();
                if (this.parentSort) {
                    this.catParentNode ||
                        EVUIEffView.emit(EVUIEffView.callNode, r.CookingCallKey.way, 0, function (t) {
                            i.catParentNode = t;
                        });
                    if (this.catParentNode) {
                        var n = QLooperNode.getNode(QLooperNode.tag_carAnimal);
                        if (n) {
                            n.parent = this.parentSort;
                            var c = a[0].path;
                            if (!(c.length < 1)) {
                                this.firstNode || (this.firstNode = n);
                                n.setPosition(c[0]);
                                ParseTool.setSortIndex(n);
                                var p = n.getComponent(s.default);
                                e &&
                                    e.data &&
                                    e.data.car_color &&
                                    p.setCarColor(new cc.Color().fromHEX(e.data.car_color));
                                p.setFoodData(e);
                                p.setBaseData(t, o, e.kindIndex, e.roadLine, a);
                            }
                        } else
                            this.scheduleOnce(function () {
                                i.addCarTask(t, e, o, a);
                            }, 0.1);
                    } else
                        this.scheduleOnce(function () {
                            i.addCarTask(t, e, o, a);
                        }, 0.1);
                } else
                    this.scheduleOnce(function () {
                        i.addCarTask(t, e, o, a);
                    }, 0.1);
            };
            e.prototype.makeCat = function (t, e, o, a, i) {
                this.addCatTask(e, o, a, i);
            };
            e.prototype.addCatTask = function (t, e, o, a) {
                var i = this;
                this.checkSort();
                if (this.parentSort) {
                    this.catParentNode ||
                        EVUIEffView.emit(EVUIEffView.callNode, r.CookingCallKey.way, 0, function (t) {
                            i.catParentNode = t;
                        });
                    if (this.catParentNode) {
                        var n = QLooperNode.getNode(QLooperNode.tag_catAnimal2);
                        if (n) {
                            n.parent = this.parentSort;
                            var s = a[0].path;
                            if (!(s.length < 1)) {
                                n.setPosition(s[0]);
                                this.firstNode || (this.firstNode = n);
                                ParseTool.setSortIndex(n);
                                var p = n.getComponent(c.default);
                                p.setFoodData(e);
                                p.setSkinData(this.getSkinData(t, e.data, o));
                                p.setBaseData(t, o, e.kindIndex, e.roadLine, a);
                            }
                        } else
                            this.scheduleOnce(function () {
                                i.addCatTask(t, e, o, a);
                            }, 0.1);
                    } else
                        this.scheduleOnce(function () {
                            i.addCatTask(t, e, o, a);
                        }, 0.1);
                } else
                    this.scheduleOnce(function () {
                        i.addCatTask(t, e, o, a);
                    }, 0.1);
            };
            e.prototype.getSkinData = function (t, e) {
                var o = {};
                o.front = ParseTool.getFront(e);
                o.back = ParseTool.getBack(e);
                return o;
            };
            e.prototype.update = function () {
                if (
                    CacheDataManager.flowerCatMove &&
                    this.firstNode &&
                    this.firstNode.parent &&
                    !GuildCache.isViewGuildDlg()
                ) {
                    var t = CacheDataManager.flowerCatMove,
                        e = Math.max(-this.firstNode.y + cc.winSize.height / 5, this.maxHeight);
                    e = Math.max(e, 0);
                    t.setContentPosition(cc.v2(t.node.x, cc.misc.lerp(t.getContentPosition().y, e, 0.1)));
                    this.maxHeight = t.getContentPosition().y;
                }
            };
            e.prototype.stopScroll = function () {
                this.firstNode = null;
                CacheDataManager.flowerCatMove = null;
            };
            return n([l], e);
        })(cc.Component));
o.default = d;
